package com.atos.smp.beans;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.ArrayList;
import java.util.List;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;


@Entity
public class Collaborator implements Serializable {
	@Id
	private String das;
	
	private String firstName;
	private String lastName;
	private String sex;
	private String nationality;
	private Date birthday;
	private String email;
	private String password;
	@Enumerated(EnumType.STRING)
	private Rule rule;
	
	
	
	@OneToMany(fetch=FetchType.LAZY)
	private List<Privilege> privilege;
	
	public Collaborator() {
		
	}

	public Collaborator(String dAS, String firstName, String lastName,Rule rule) {
		super();
		setDas(dAS);
		this.firstName = firstName;
		this.lastName = lastName;
		this.rule = rule;
	}
	public Rule getRule() {
		return rule;
	}

	public void setRule(Rule rule) {
		this.rule = rule;
	}

	public String getDas() {
		return das;
	}

	public void setDas(String das) {
		this.das = das;
	}

	public Collaborator(String dAS, String firstName, String lastName,
			String sex, String nationality, Date birthday, String email,
			String password,Rule rule) {
		super();
		setDas(dAS);
		this.firstName = firstName;
		this.lastName = lastName;
		this.sex = sex;
		this.nationality = nationality;
		this.birthday = birthday;
		this.email = email;
		this.password = password;
		this.rule = rule;

	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		System.out.println(lastName);
		this.lastName = lastName;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public Date getBirthday() {
		return birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}


	public String getNationality() {
		return nationality;
	}

	public void setNationality(String nationality) {
		this.nationality = nationality;
	}

	public List<Privilege> getPrivilege() {
		return privilege;
	}

	public void setPrivilege(List<Privilege> privilege) {
		this.privilege = privilege;
	}

	public String toString() {
		return firstName +" "+ lastName ;
	}
	public boolean equals(Object c) {
		if(c instanceof Collaborator)
			return (this.das == ((Collaborator)c).das);
		else
			return super.equals(c);
	}

	

}
